@mixin extjs-tree {

  // Declare some 'constants' for the image sprites
  $PLUS_NO_LINES: -0 * $tree-elbow-width;
  $MINUS_NO_LINES: -1 * $tree-elbow-width;
  $RIGHT_ARROW_NO_LINES: -2 * $tree-elbow-width;
  $DOWN_ARROW_NO_LINES: -3 * $tree-elbow-width;
  $PLUS_WITH_LINES: -4 * $tree-elbow-width;
  $PLUS_WITH_LINES_LAST_CHILD: -5 * $tree-elbow-width;
  $MINUS_WITH_LINES: -6 * $tree-elbow-width;
  $MINUS_WITH_LINES_LAST_CHILD: -7 * $tree-elbow-width;
  $RIGHT_ARROW_WITH_LINES: -8 * $tree-elbow-width;
  $RIGHT_ARROW_WITH_LINES_LAST_CHILD: -9 * $tree-elbow-width;
  $DOWN_ARROW_WITH_LINES: -10 * $tree-elbow-width;
  $DOWN_ARROW_WITH_LINES_LAST_CHILD: -11 * $tree-elbow-width;
  $CLOSED_FOLDER_NO_LINES: -12 * $tree-elbow-width;
  $CLOSED_FOLDER_WITH_LINES: -13 * $tree-elbow-width;
  $OPEN_FOLDER_NO_LINES: -15 * $tree-elbow-width;
  $OPEN_FOLDER_WITH_LINES: -16 * $tree-elbow-width;
  $LEAF_NO_LINES: -18 * $tree-elbow-width;
  $LEAF_WITH_LINES: -19 * $tree-elbow-width;

  // Tree tables must assume either full width of the View element, or, when necessary, must overflow
  // They must not shrink wrap the width and only be as wide as their widest node's content.
  .#{$prefix}autowidth-table table.#{$prefix}grid-table {
    table-layout: auto;
    width: auto !important;
  }

  .#{$prefix}tree-elbow-plus,
  .#{$prefix}tree-elbow-minus,
  .#{$prefix}tree-elbow-end-plus,
  .#{$prefix}tree-elbow-end-minus {
    cursor: pointer;
  }

  .#{$prefix}tree-icon {
    margin-right: 4px;
  }

  .#{$prefix}tree-elbow,
  .#{$prefix}tree-elbow-line,
  .#{$prefix}tree-elbow-end,
  .#{$prefix}tree-elbow-plus,
  .#{$prefix}tree-elbow-minus,
  .#{$prefix}tree-elbow-end-plus,
  .#{$prefix}tree-elbow-end-minus,
  .#{$prefix}tree-icon-end,
  .#{$prefix}tree-icon-end-plus,
  .#{$prefix}tree-icon-leaf,
  .#{$prefix}tree-elbow-empty,
  .#{$prefix}tree-icon-parent {
    height: $tree-elbow-height;
    width: $tree-elbow-width;
  }

  .#{$prefix}tree-lines .#{$prefix}tree-elbow,
  .#{$prefix}tree-lines .#{$prefix}tree-elbow-line,
  .#{$prefix}tree-lines .#{$prefix}tree-elbow-end,
  .#{$prefix}tree-elbow-plus,
  .#{$prefix}tree-elbow-minus,
  .#{$prefix}tree-elbow-end-plus,
  .#{$prefix}tree-elbow-end-minus,
  .#{$prefix}tree-icon-end,
  .#{$prefix}tree-icon-end-plus,
  .#{$prefix}tree-icon-leaf,
  .#{$prefix}tree-icon-parent {
    background-image: theme-background-image($theme-name, 'tree/elbows.png');
  }

  //+/-, no lines
  .#{$prefix}tree-elbow-plus,
  .#{$prefix}tree-elbow-end-plus {
    background-image: theme-background-image($theme-name, 'tree/icons-gray.png');
    background-position: $PLUS_NO_LINES 0;
  }

  .#{$prefix}grid-tree-node-expanded .#{$prefix}tree-elbow-plus,
  .#{$prefix}grid-tree-node-expanded .#{$prefix}tree-elbow-end-plus {
    background-image: theme-background-image($theme-name, 'tree/icons-gray.png');
    background-position: $MINUS_NO_LINES 0;
  }

  //+/-, lines
  .#{$prefix}tree-lines {
    .#{$prefix}tree-elbow-plus {
      background-image: theme-background-image($theme-name, 'tree/icons-gray.png');
      background-position: $PLUS_WITH_LINES 0;
    }

    .#{$prefix}tree-elbow-end-plus {
      background-image: theme-background-image($theme-name, 'tree/icons-gray.png');
      background-position: $PLUS_WITH_LINES_LAST_CHILD 0;
    }

    .#{$prefix}grid-tree-node-expanded .#{$prefix}tree-elbow-plus {
      background-image: theme-background-image($theme-name, 'tree/icons-gray.png');
      background-position: $MINUS_WITH_LINES 0;
    }

    .#{$prefix}grid-tree-node-expanded .#{$prefix}tree-elbow-end-plus {
      background-image: theme-background-image($theme-name, 'tree/icons-gray.png');
      background-position: $MINUS_WITH_LINES_LAST_CHILD 0;
    }
  }

  //arrows, no lines
  .#{$prefix}tree-arrows {
    .#{$prefix}tree-elbow-plus,
    .#{$prefix}tree-elbow-end-plus {
      background-position: $RIGHT_ARROW_NO_LINES 0;
    }

    .#{$prefix}grid-tree-node-expanded .#{$prefix}tree-elbow-plus,
    .#{$prefix}grid-tree-node-expanded .#{$prefix}tree-elbow-end-plus {
      background-position: $DOWN_ARROW_NO_LINES 0;
    }
  }

  .#{$prefix}tree-arrows {
    &.#{$prefix}tree-lines {
      .#{$prefix}tree-elbow-plus {
        background-position: $RIGHT_ARROW_WITH_LINES 0;
      }

      .#{$prefix}tree-elbow-end-plus {
        background-position: $RIGHT_ARROW_WITH_LINES_LAST_CHILD 0;
      }

      .#{$prefix}grid-tree-node-expanded .#{$prefix}tree-elbow-plus {
        background-position: $DOWN_ARROW_WITH_LINES 0;
      }

      .#{$prefix}grid-tree-node-expanded .#{$prefix}tree-elbow-end-plus {
        background-position: $DOWN_ARROW_WITH_LINES_LAST_CHILD 0;
      }
    }
  }

  //folder, no lines
  .#{$prefix}tree-icon-parent {
    background-position: $CLOSED_FOLDER_NO_LINES 0 !important;
    background-image: theme-background-image($theme-name, 'tree/icons-orange.png');
  }

  .#{$prefix}grid-tree-node-expanded .#{$prefix}tree-icon-parent {
    background-position: $OPEN_FOLDER_NO_LINES 0 !important;
  }

  .#{$prefix}tree-icon-leaf {
    background-position: $LEAF_NO_LINES 0 !important;
  }

  //folder, lines
  .#{$prefix}tree-lines {
    .#{$prefix}tree-icon-parent {
      width: $tree-elbow-width;
      background-position: $CLOSED_FOLDER_WITH_LINES 0 !important;
    }

    .#{$prefix}grid-tree-node-expanded .#{$prefix}tree-icon-parent {
      background-position: $OPEN_FOLDER_WITH_LINES 0 !important;
    }
  }

  //leaf, no lines
  .#{$prefix}tree-icon-leaf {
    width: $tree-elbow-width;
    background-position: $LEAF_NO_LINES 0 !important;
    background-image: theme-background-image($theme-name, 'tree/icons-orange.png');
  }

  .#{$prefix}tree-lines {
    .#{$prefix}tree-icon-leaf {
      background-position: $LEAF_WITH_LINES 0 !important;
    }
  }

  //selected row
  .x-grid-row-selected {
    .#{$prefix}tree-elbow-plus,
    .#{$prefix}tree-elbow-minus,
    .#{$prefix}tree-elbow-end-plus,
    .#{$prefix}tree-elbow-end-minus,
    .#{$prefix}tree-icon-end,
    .#{$prefix}tree-icon-end-plus,
    .#{$prefix}tree-icon-leaf,
    .#{$prefix}tree-icon-parent {
      background-image: theme-background-image($theme-name, 'tree/icons-white.png') !important;
    }
  }

  // lines
  .#{$prefix}tree-lines {
    .#{$prefix}tree-elbow-line {
      background-image: theme-background-image($theme-name, 'tree/elbows.png');
      background-position: 0 $tree-elbow-height * 2;
    }

    .#{$prefix}tree-elbow {
      background-image: theme-background-image($theme-name, 'tree/elbows.png');
      background-position: 0 $tree-elbow-height * 0;
    }

    .#{$prefix}tree-elbow-end {
      background-image: theme-background-image($theme-name, 'tree/elbows.png');
      background-position: 0 $tree-elbow-height * 1;
    }
  }

  //    .#{$prefix}grid-with-row-lines {
  //        .#{$prefix}tree-elbow,
  //        .#{$prefix}tree-elbow-end,
  //        .#{$prefix}tree-elbow-plus,
  //        .#{$prefix}tree-elbow-end-plus,
  //        .#{$prefix}tree-elbow-empty,
  //        .#{$prefix}tree-elbow-line {
  //            height: $tree-elbow-height - 1;
  //            background-position: 0 -1px;
  //        }
  //    }

  .#{$prefix}grid-cell-treecolumn .#{$prefix}grid-cell-inner {
    padding: 0;
    line-height: $tree-elbow-height - 1;
  }

  .#{$prefix}grid-with-row-lines .#{$prefix}grid-cell-treecolumn .#{$prefix}grid-cell-inner {
    line-height: $tree-elbow-height - 3;
  }

  .#{$prefix}tree-panel .#{$prefix}grid-cell-inner {
    cursor: pointer;

    img {
      display: inline-block;
      vertical-align: top;
    }
  }

  //    @if $include-ie {
  //        .#{$prefix}ie .#{$prefix}tree-panel {
  //            .#{$prefix}tree-elbow,
  //            .#{$prefix}tree-elbow-end,
  //            .#{$prefix}tree-elbow-plus,
  //            .#{$prefix}tree-elbow-end-plus,
  //            .#{$prefix}tree-elbow-empty,
  //            .#{$prefix}tree-elbow-line {
  //                // vertical alignment is necessary for IE to show the ellipsis in the right place.
  //                vertical-align: -6px;
  //            }
  //        }
  //    }

  //    .#{$prefix}tree-panel .#{$prefix}grid-editor-on-text-node {
  //        .#{$prefix}form-text {
  //            // specify padding left and padding right individually since we don't want to override padding-bottom (which can vary)
  //            padding-left: $grid-cell-treecolumn-editor-field-padding-horizontal;
  //            padding-right: $grid-cell-treecolumn-editor-field-padding-horizontal;
  //        }
  //    }
  //    @if $include-ie {
  //        .#{$prefix}ie .#{$prefix}tree-panel .#{$prefix}grid-editor-on-text-node .#{$prefix}form-text {
  //            padding-left: $grid-cell-treecolumn-editor-field-padding-horizontal + 1px;
  //            padding-right: $grid-cell-treecolumn-editor-field-padding-horizontal + 1px;
  //        }
  //    }
  //    @if $include-opera {
  //        .#{$prefix}opera .#{$prefix}tree-panel .#{$prefix}grid-editor-on-text-node .#{$prefix}form-text {
  //            padding-left: $grid-cell-treecolumn-editor-field-padding-horizontal + 1px;
  //            padding-right: $grid-cell-treecolumn-editor-field-padding-horizontal + 1px;
  //        }
  //    }

  .#{$prefix}tree-checkbox {
    margin: $tree-checkbox-margin-top $tree-checkbox-margin-right 0 0;
    display: inline-block;
    vertical-align: top;

    width: $form-checkbox-size;
    height: $form-checkbox-size;
    background: no-repeat;
    background-image: theme-background-image($theme-name, $form-checkbox-image);

    overflow: hidden;
    padding: 0;
    border: 0;

    &::-moz-focus-inner {
      padding: 0;
      border: 0;
    }
  }

  .#{$prefix}grid-with-row-lines .#{$prefix}tree-checkbox {
    margin-top: $tree-checkbox-margin-top - 1;
  }

  .#{$prefix}tree-checkbox-checked {
    background-position: 0 (0 - $form-checkbox-size);
  }

  .#{$prefix}tree-drop-ok-append .#{$prefix}dd-drop-icon {
    background-image: theme-background-image($theme-name, 'tree/drop-append.gif');
  }

  .#{$prefix}tree-drop-ok-above .#{$prefix}dd-drop-icon {
    background-image: theme-background-image($theme-name, 'tree/drop-above.gif');
  }

  .#{$prefix}tree-drop-ok-below .#{$prefix}dd-drop-icon {
    background-image: theme-background-image($theme-name, 'tree/drop-below.gif');
  }

  .#{$prefix}tree-drop-ok-between .#{$prefix}dd-drop-icon {
    background-image: theme-background-image($theme-name, 'tree/drop-between.gif');
  }

  .#{$prefix}grid-tree-loading .#{$prefix}tree-icon {
    background-image: theme-background-image($theme-name, 'tree/loading.gif');
  }

  .#{$prefix}tree-ddindicator {
    height: 1px;
    border-width: 1px 0px 0px;
    border-style: dotted;
    border-color: green;
  }

  .#{$prefix}grid-tree-loading span {
    font-style: italic;
    color: #444444;
  }

  .#{$prefix}tree-animator-wrap {
    overflow: hidden;
  }
}